package com.geek.javase.ch17.work.bswork;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/*
 *@Date 2025/11/4
 *@Author wangpeng
 *@Description TODO
 */
public class ThreadPool {
    private ThreadPoolExecutor pool;
    //创建线程池
    public ThreadPool(int maxPoolSize, int queueSize) {
        pool = new ThreadPoolExecutor(
                2, maxPoolSize,
                60, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(queueSize));
    }
    //执行方法
    public void execute(Runnable runnable) {
        pool.execute(runnable);
    }
}
